Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust SAFE_URL_PATTERN regex for use with test method of regexes. #33153

Merged
merged 2 commits into from
Mar 2, 2021

Conversation

nikonthethird
Copy link
Contributor

@nikonthethird nikonthethird commented Feb 19, 2021

Follow-up PR of #33136 for Bootstrap 4.

This also removes the global modifier from the SAFE_URL_PATTERN regex, see the other PR for details why.

Since Bootstrap V4 uses a different unit testing strategy than V5, based on the dist files, the sanitizer is not directly accessible since the file is inlined into tooltip.js. Therefore, the unit test for the sanitation has been added to the tooltip unit tests and simply adds two tooltips with the same HTML template to the test fixture. Then it checks that the tooltips contents are correct, using the same logic as the unit test in V5.

I verified that the test works by first running it with the global modifier on the regex, where it fails, then removing the global modifier and it passes.

The `test` method on regexes does not behave like `match` on strings
for checks if the regex matches when the global modifier (g) is present.

Also adds a unit test on tooltips for sanitizing the same template twice.
@nikonthethird nikonthethird requested a review from a team as a code owner February 19, 2021 11:20
@XhmikosR
Copy link
Member

XhmikosR commented Mar 2, 2021

@nikonthethird thank you for the backport!

@XhmikosR XhmikosR merged commit 7ad0625 into twbs:v4-dev Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants